﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using ZR.DataCollection.OperationCore.OperationEnum;

namespace ZR.DataCollection.OperationCore.ExtensionMethod
{
    public static class OperationExtension
    {
        /// <summary>
        /// 数据库中监控点位的PointId;返回代码中代表的操作类型
        /// </summary>
        /// <param name="oi">Item序号</param>
        /// <returns></returns>
        public static OperationTypeEnum OperationInfoByItem(this int oi)
        {
            switch (oi)
            {
                //加工请求
                case 3:
                    return OperationTypeEnum.Process;
                //保存请求
                case 6:
                    return OperationTypeEnum.Save;
                //批次码请求
                case 8:
                    return OperationTypeEnum.BatchCode;

                case 11:
                    return OperationTypeEnum.BatchCode;

                case 14:
                    return OperationTypeEnum.BatchCode;

                case 17:
                    return OperationTypeEnum.BatchCode;

                case 20:
                    return OperationTypeEnum.BatchCode;

                default:
                    return OperationTypeEnum.Default;
            }
        }

        /// <summary>
        /// 根据工站名称返回StationEnum
        /// </summary>
        /// <param name="si">工位代号</param>
        /// <returns></returns>
        public static StationEnum StationInfoByItem(this string si)
        {
            switch (si)
            {
                case "OP10":
                    return StationEnum.StationOne;

                case "OP20":
                    return StationEnum.StationTwo;

                case "OP30":
                    return StationEnum.StationThree;

                case "OP40":
                    return StationEnum.StationFour;
                //默认工站
                default:
                    return StationEnum.StationDefalut;
            }
        }

        /// <summary>
        /// 根据StationEnum返回工站名称
        /// </summary>
        /// <param name="no"></param>
        /// <returns></returns>
        public static string StationCodeByNo(this int no)
        {
            switch (no)
            {
                case 1:
                    return "OP010";

                case 2:
                    return "OP020";

                case 3:
                    return "OP030";

                case 4:
                    return "OP040";

                case 5:
                    return "OP050";

                case 6:
                    return "OP060";

                case 7:
                    return "OP070";

                case 8:
                    return "OP080";

                default:
                    return string.Empty;
            }
        }
    }
}